% callback routine load_default_values
% reads default parameters from file
% and fills them into the parameter space

HandleEditTextHR=findobj(gcf,'Tag','EditTextHR');
HR=str2num(get(HandleEditTextHR,'String'));

HandleEditTextEmaxV=findobj(gcf,'Tag','EditTextEmaxV');
EmaxV=str2num(get(HandleEditTextEmaxV,'String'));

HandleEditTextTEmaxV=findobj(gcf,'Tag','EditTextTEmaxV');
TEmaxV=str2num(get(HandleEditTextTEmaxV,'String'));

HandleEditTextEminV=findobj(gcf,'Tag','EditTextEminV');
EminV=str2num(get(HandleEditTextEminV,'String'));

HandleEditTextVdeadV=findobj(gcf,'Tag','EditTextVdeadV');
VdeadV=str2num(get(HandleEditTextVdeadV,'String'));

HandleEditTextPvenous=findobj(gcf,'Tag','EditTextPvenous');
Pvenous=str2num(get(HandleEditTextPvenous,'String'));

HandleEditTextZ0=findobj(gcf,'Tag','EditTextZ0');
Z0=str2num(get(HandleEditTextZ0,'String'));

HandleEditTextL=findobj(gcf,'Tag','EditTextL');
L=str2num(get(HandleEditTextL,'String'));

HandleEditTextC=findobj(gcf,'Tag','EditTextC');
C=str2num(get(HandleEditTextC,'String'));

HandleEditTextR=findobj(gcf,'Tag','EditTextR');
R=str2num(get(HandleEditTextR,'String'));

HandleEditTextT_interval=findobj(gcf,'Tag','EditTextT_interval');
t_interval=str2num(get(HandleEditTextT_interval,'String'));

HandleEditTextRmv=findobj(gcf,'Tag','EditTextRmv');
Rmvfwd=str2num(get(HandleEditTextRmv,'String'));

HandleEditTextRao=findobj(gcf,'Tag','EditTextRao');
Raofwd=str2num(get(HandleEditTextRao,'String'));

HandleEditTextRmvbwd=findobj(gcf,'Tag','EditTextRmvbwd');
Rmvbwd=str2num(get(HandleEditTextRmvbwd,'String'));

HandleEditTextRaobwd=findobj(gcf,'Tag','EditTextRaobwd');
Raobwd=str2num(get(HandleEditTextRaobwd,'String'));

[FILENAME, PATHNAME] = uiputfile('*.dat', 'File with default values');
fname=[PATHNAME FILENAME '.dat'];
[fid1,message]=fopen(fname,'w');

if fid1==-1
   error('File %s could not be opened',fname);
end;

fprintf(fid1,'HR: %g\n',HR);						% heart period = duration 1 cycle
fprintf(fid1,'Emax_V: %g\n',EmaxV);			% Emax ventricle
fprintf(fid1,'TEmax_V: %g\n',TEmaxV);			% time Emax ventricle
fprintf(fid1,'Emin_V: %g\n',EminV);			% Emin ventricle
fprintf(fid1,'Vdead_V: %g\n',VdeadV);			% dead LV volume
fprintf(fid1,'Pvenous: %g\n',Pvenous);	% LA filling pressure
fprintf(fid1,'Rmvfwd: %g\n',Rmvfwd);				% mitral valve resistance
fprintf(fid1,'Raofwd: %g\n',Raofwd);				% aortic valve resistance
fprintf(fid1,'Rmvbwd: %g\n',Rmvbwd);				% mitral valve resistance
fprintf(fid1,'Raobwd: %g\n',Raobwd);				% aortic valve resistance
fprintf(fid1,'Z0: %g\n',Z0);					% characteristic impedance
fprintf(fid1,'L: %g\n',L);					% inertance	% if L = 0, use a 3-element WK model 
fprintf(fid1,'C: %g\n',C);					% compliance
fprintf(fid1,'R: %g\n',R);					% resistance
fprintf(fid1,'dT: %g\n',t_interval);		% time interval

fclose(fid1);

